<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>

  // const p1 = new Promise((resolve, reject) => {
  //   console.log(1)
  //   setTimeout(() => {
  //     resolve(1)
  //   }, 1000)
  // })
  // const p2 = new Promise((resolve, reject) => {
  //   console.log(2)
  //   setTimeout(() => {
  //     resolve(1)
  //   }, 2000)
  // })
  // const p3 = new Promise((resolve, reject) => {
  //   console.log(3)
  //   setTimeout(() => {
  //     resolve(1)
  //   }, 3000)
  // })
  //
  // Promise.MyAll = function (promises) {
  //   let arr = [],
  //     count = 0
  //   return new Promise((resolve, reject) => {
  //     promises.forEach((item, i) => {
  //       Promise.resolve(item).then(res => {
  //         arr[i] = res
  //         count += 1
  //         if (count === promises.length) resolve(arr)
  //       }, reject)
  //     })
  //   })
  // }
  // Promise.all([p1, p2, p3, 1]).then(res => {
  //   console.log(res)
  // })
</script>
</body>
</html>
